<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
class Feed extends CActiveRecord{

	const TYPE_TWITTER=1;//说说
	const TYPE_BLOG_MSG=2;//写文章
	const TYPE_PIC_MSG=3;//发图片

	public static function model($className=__CLASS__){
		return parent::model($className);
	}

	public function tableName(){
		return 'feed';
	}	

	public static function desc($type=false){
		$ts = array(self::TYPE_TWITTER =>'说',self::TYPE_BLOG_MSG=>'发布文章',self::TYPE_PIC_MSG=>'上传图片' );
		return $type?$ts[$type]:$ts;
	}
	public static function addfeed($type,$link){
		if($type){
			$date=date('Y-m-d H:i:s');
			$feed = new Feed;
			$feed->uid = Yii::app()->user->id;
			$feed->type=$type;
			$feed->link=$link;
			$feed->date=$date;
			$feed->save();
		}
	}

}